﻿@{
    ViewBag.Title = "用户登录日志";
    int pageIndex = TempData["pageIndex"] == null ? 1 : (int)TempData["pageIndex"];
    Searcher searcher = TempData["searcher"] as Searcher;
}
@Styles.Render("~/Content/themes/base/css")
@Styles.Render("~/Content/list")
<div id="adsearch">
    @using (Ajax.BeginForm("Grid", new AjaxOptions { UpdateTargetId = "gridview", LoadingElementId = "loading" }))
    {
        <div style="width: 85%; float: left;">
            <table class="searchbar">
                <tr>
                    <th>
                        用户名:
                    </th>
                    <td>
                        @Html.TextBox("ad.UserName")
                    </td>
                     <th>
                    登录日期(起):
                </th>
                <td>
                    @Html.TextBox("ad.StartDate", null, new { @class = "datepicker", @readonly = "readonly" })
                </td>
                <th>
                    登录日期(止):
                </th>
                <td>
                    @Html.TextBox("ad.EndDate", null, new { @class = "datepicker", @readonly = "readonly" })
                </td>
                </tr>
            </table>
        </div>
        <p>
            <input class="button" type="submit" value="查询" />
            <input class="button" type="button" value="导出" id="btnexport" />
        </p>
    }
</div>
<div id="loading" class="loading">
    <img src="@Url.Content("~/Images/icon-loader.gif")" alt="Searching" />
</div>
<div id="gridview">
    @{ Html.RenderAction("Grid", new { pageIndex = pageIndex, searcher = searcher });}
</div>
@section scripts{
    @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/bundles/cascade")

    <script type="text/javascript">
        $(function ()
        {

            $.datepicker.setDefaults($.datepicker.regional["zh-TW"]);
            $(".datepicker").datepicker({
                showOn: "button",
                buttonImage: '@Url.Content("~/Images/calendar.gif")',
                buttonImageOnly: true,
                changeMonth: true,
                changeYear: true,
                dateFormat: "yy-mm-dd"
            });
            $(".ui-datepicker-trigger").css("cursor", "pointer");

            $("#btnexport").click(function () {
                var startdate = $("#ad_StartDate");
                var enddate = $("#ad_EndDate");
                if (startdate.val() != "" && enddate.val() != "" && (startdate.val() > enddate.val())) {
                    alert("结束日期不能小于开始日期！");
                }
                else {
                    Export('form0', '@Url.Action("Export")');
                }
            });
            
        });
    </script>
}

